package com.boot.unity.api.utils;

import lombok.experimental.UtilityClass;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author X
 * @create 2020-10-13 14:05
 */
@UtilityClass
public class DateUtil {
    public static final DateTimeFormatter NORM_DATETIME_PATTERN = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    public static final DateTimeFormatter NORM_DATE_PATTERN = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    /**
     * 获取yyyy-MM-dd HH:mm:ss时间字符串
     * @return
     */
    public static String getNormalDateTimeString(){
        LocalDateTime dateTime = LocalDateTime.now();
        return NORM_DATETIME_PATTERN.format(dateTime);
    }

    /**
     * 获取yyyy-MM-dd时间字符串
     * @return
     */
    public static String getNormalDateString(){
        LocalDate localDate = LocalDate.now();
        return localDate.toString();
    }
}
